package day3.demo6_优先级;

public class Test {
    public static void main(String[] args) {
        Runnable r1 = new Runnable() {
            @Override
            public void run() {
                int i = 0;
                while (true){
                    Thread t = Thread.currentThread();
                    System.out.println(t.getName()+"优先级："+t.getPriority()+",i="+i++);
                }
            }
        };

        Runnable r2 = new Runnable() {
            @Override
            public void run() {
                int i = 0;
                while (true){
                    Thread t = Thread.currentThread();
                    System.out.println(t.getName()+"优先级："+t.getPriority()+",i="+i++);
                }
            }
        };

        Thread t1 = new Thread(r1, "=======================一号线程");
        t1.setPriority(1);
        Thread t2 = new Thread(r2, "二号线程");
        t2.setPriority(9);

        t1.start();
        t2.start();
    }
}
